<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String p=request.getParameter("phone");
String iswx=request.getParameter("iswx");
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>登录</title>
<meta name="viewport" id="view" name="view" content="width=device-width,height=device-height, initial-scale=1.0, user-scalable=no,minimum-scale = 1.0,maximum-scale = 5.0," />
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="登录,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="./css/weui.css" />
<link rel="stylesheet" href="./css/example.css" />
<link rel="stylesheet" href="./css/wx.css" />
<link rel="stylesheet" href="./js/font-awesome/css/font-awesome.min.css">
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/zepto.min.js"></script>
<script type="text/javascript" src="./js/example.js"></script>
<script type="text/javascript" src="./js/login.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<style type="text/css">
.input_style{
	border: 1px solid rgba(3, 169, 244, 0.42);
	background-color: #fff;
	display: inline !important;
	border-radius: 3px;
    height: 30px;
    margin-top: 10px;
}
.red_btn{
	padding: 5px;
    border-radius: 3px;
    background-color: #654545;
    color: #fff;
}
.green_btn{
	padding: 5px;
    border-radius: 3px;
    background-color: #1da005;
    color: #fff;
}
</style>
</head>
<script type="text/javascript">
var basePath="<%=basePath%>";
var iswx = <%=iswx%>;//接入微信端菜单使用
// 屏蔽屏幕自身手势
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
var dianhua="<%=p%>";
function showbmiBox(){
	$("#bmiBox").show();
}

function bmi_OK(){
	var my_height = $("#my_height").val();
	var bodyWeight = $("#bodyWeight").val();
	if(my_height=='' || bodyWeight==''){
		alert("请填写好信息");
	}else{
		$.ajax({
	        url: "./user/addBMIRecord.spring",
	        data: {
	        	userCode : storage.getItem("primaryRole"),
				roleCode : storage.getItem("currentRole"),
				bodyWeight : bodyWeight,
				height : my_height
	        },
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
	        	if(ret.resultCode==0){
					alert("保存成功");
					bmi = {
						my_height : my_height,
						bodyWeight : bodyWeight
					};
					var BMI = returnBMI(my_height,bodyWeight);
					alert("你的BMI值："+BMI+",属于"+returnBMItxet(BMI));
					bmi_NO();
					jump();
	        	}else{
	        		alert("保存失败");
	        	}
	        }
		});		
	}
}

function returnBMI(height,bodyWeight){
	var m = height/100;
	return bodyWeight/m/m;
}

function returnBMItxet(value){
	if(value<18.5){
		return '偏瘦';
	}else if(value>18.5 && value<23.9){
		return '正常';
	}else if(value>24 && value<26.9){
		return '偏胖';
	}else if(value>27 && value<29.9){
		return '肥胖';
	}else if(value>=30 && value<40){
		return '重度肥胖';
	}else{
		return '极重度肥胖';
	}
}

function bmi_NO(){
	$("#my_height").val('');
	$("#bodyWeight").val('');
	$("#bmiBox").hide();
}

</script>

<body ontouchstart>
	<div class="container js_container"></div>
	<div class="page">
		<div class="bd">
			<div class="weui_grids">
				<div style="text-align: center;margin-top: 50px;">
					<img alt="" src="./images/logo3.jpg" width="55%" height="100px;"><br>
				</div>
			</div>
			<div class="weui_cell" style="margin-top: 20px;">
				<div class="weui_cell_hd">
					<label class="weui_label" style="width: 6em">手机号码：</label>
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="number" name="phone" id="phone" placeholder="请输入手机号码">
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd">
					<label class="weui_label" style="width: 6em">密   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</label>
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="password" name="psw" id="psw" placeholder="请输入密码" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')">
				</div>
			</div>
		</div>
		<div class="weui_btn_area">
			<a class="weui_btn weui_btn_primary login" href="javascript:"
				id="showTooltips" onclick="toSave();">登录</a>
		</div>
		<div class="weui_extra_area" style="position: static;font-size:14px;text-align: right !important;">
			<a href="javaScript:;" onclick="forgetPsw();" style="color: #969696;margin-right: 5px;">忘记密码?</a>
			|
			<span style="color: #969696;margin-left: 5px;">还没有账号？</span>
            <a onclick="toRegister();" style="color: #1c90f6;margin-right: 15px;">15秒注册</a>
        </div>
	</div>
	
	<div class="weui_dialog_confirm" id="bmiBox" style="display: none;">
	    <div class="weui_mask"></div>
	    <div class="weui_dialog" style="height: auto!important;height: 160px;min-height: 160px;padding-top: 10px;border-radius: 8px;">
	    	<label>欢迎回来，今天您健康了么</label>
	    	<div style="font-size: 12px;">
	    		<label>身高：</label>
	    		<input id="my_height" class="form-control input_style" placeholder="请输入身高，单位CM"/>
	    	</div>
	    	<div style="font-size: 12px;">
	    		<label>体重：</label>
	    		<input id="bodyWeight" class="form-control input_style" placeholder="请输入体重，单位KG"/>
	    	</div>
	    	<div style="margin-top: 13px;">
	    		<a class="green_btn" onclick="bmi_OK()">去测试</a>
	    		<a class="red_btn" onclick="jump()">我跳过</a>
	    	</div>
	    </div>
	</div>
	
	<div id="loadingToast" class="weui_loading_toast" style="display: none;">
				<div class="weui_mask_transparent"></div>
				<div class="weui_toast">
					<div class="weui_loading">
						<div class="weui_loading_leaf weui_loading_leaf_0"></div>
						<div class="weui_loading_leaf weui_loading_leaf_1"></div>
						<div class="weui_loading_leaf weui_loading_leaf_2"></div>
						<div class="weui_loading_leaf weui_loading_leaf_3"></div>
						<div class="weui_loading_leaf weui_loading_leaf_4"></div>
						<div class="weui_loading_leaf weui_loading_leaf_5"></div>
						<div class="weui_loading_leaf weui_loading_leaf_6"></div>
						<div class="weui_loading_leaf weui_loading_leaf_7"></div>
						<div class="weui_loading_leaf weui_loading_leaf_8"></div>
						<div class="weui_loading_leaf weui_loading_leaf_9"></div>
						<div class="weui_loading_leaf weui_loading_leaf_10"></div>
						<div class="weui_loading_leaf weui_loading_leaf_11"></div>
					</div>
					<p class="weui_toast_content">正在登录...</p>
				</div>
			</div>
			
	<div id="toast" style="display: none;">
        <div class="weui_mask_transparent"></div>
        <div class="weui_toast">
            <i class="weui_icon_toast"></i>
            <p class="weui_toast_content">登录成功</p>
        </div>
    </div>
</body>
</html>
